<template>
  <div>
    <h1>登录页面</h1>

    <button @click="handleLogin">登录1</button>
  </div>
</template>

<script>
export default {
  methods: {
    handleLogin() {
      setTimeout(() => {
        // 登录成功
        localStorage.setItem('token', 'TOKEN')

        // 跳转回首页
        // this.$router.push('/films')

        // 获取 redirect 参数的值
        const redirect = this.$route.query.redirect || '/films'
        console.log('redirect', redirect)
        this.$router.replace(redirect)

      }, 1000)
    }
  }
}
</script>